package GraphProperties;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import Global.ConstantVariable;
import Global.ConstantVariable.Matlab_ConstantVariables;
import Global.DirectoryStructureAndSettingsClass;
import Global.GlobalClass;
import SyntheticData.syntheticDataGeneratorClass;
import SyntheticData.syntheticDataGeneratorClass.TogetherFilesHolderClass;
import Utility.ListsPerGivenLevelsHolderClass;
import Utility.WorkerUtilityClass;

public class LocalAlphaRelatedPropsClass extends GenericGraphPropertyClass implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4137491179099506313L;
	double[] localAlphaListOfTheNodes;
	double localAlphaOfTheGraph;
	
	double[] localAlphaDistrubutionVsDegreeLevels;
	double[] localAlphaDistrubutionErrorBarsVsDegreeLevels;
	
	double[] localAlphaLevels;
	double[] localAlphaFrequencyForTheLevels;
	
	double[] localAlphaDistrubutionVsCC;
	double[] localAlphaDistrubutionErrorBarsVsCC;
		
	double[] localAlphaDistrubutionVsHomophily;
	double[] localAlphaDistrubutionErrorBarsVsHomophily;
	
	
	double[] precisionIntervalsForLocalAlphaDiscritization;	//asil bu.
	int lengthOfTheLocalAlphaIntervals;
	
	/********************************/	

	protected LocalAlphaRelatedPropsClass(PropertiesOfGraphClass propertiesIBelongTo) 
	{
		super(propertiesIBelongTo);
		localAlphaOfTheGraph = 0;
	}
	
	public void setLocalAlphaOfTheNodesAndRelatedParameters(double[] localAlphaListOfTheNodes, double localAlphaOfTheGraph)
	{
		this.localAlphaListOfTheNodes = localAlphaListOfTheNodes;			
		this.localAlphaOfTheGraph = localAlphaOfTheGraph;
		
		lengthOfTheLocalAlphaIntervals = (int) Math.ceil(1.0/ConstantVariable.LocalAlphaRelated_ConstantVariables.PRECISION_LEVEL_FOR_LA_DISCRETIZATON)+1;
		precisionIntervalsForLocalAlphaDiscritization=  new double[lengthOfTheLocalAlphaIntervals];
		
		calculateLocalAlphaVsDegreeDistribution();
		analyzeLocalAlphaDistributionOfTheGraph();
		System.out.println("After analyzeLocalAlphaDistributionOfTheGraph");
		calculateLocalAlphaVsCCDistribution();
		System.out.println("After calculateLocalAlphaVsCCDistribution");
		calculateLocalAlphaVsHomophilyDistribution();
		System.out.println("After calculateLocalAlphaVsHomophilyDistribution");
		localAlphaCalculationIsCompleted();
		System.out.println("After localAlphaCalculationIsCompleted");
	}
	
	public void setLocalAlphaVsDegreeDistribution(double[] localAlphaDistrubutionVsDegreeLevels)
	{
		this.localAlphaDistrubutionVsDegreeLevels = localAlphaDistrubutionVsDegreeLevels;				
	}
	
	public void setLocalAlphaVsCCRelatedParameters(double[] localAlphaDistrubutionVsCCLevels, double[] localAlphaDistrubutionErrorBarsVsCCLevels) 
	{
		localAlphaDistrubutionVsCC = localAlphaDistrubutionVsCCLevels;
		localAlphaDistrubutionErrorBarsVsCC = localAlphaDistrubutionErrorBarsVsCCLevels;		
	}
	
	public void setLocalAlphaVsHomophilyRelatedParameters(double[] localAlphaDistrubutionVsHomophilyLevels, double[] localAlphaDistrubutionErrorBarsVsHomophilyLevels) 
	{
		localAlphaDistrubutionVsHomophily = localAlphaDistrubutionVsHomophilyLevels;
		localAlphaDistrubutionErrorBarsVsHomophily = localAlphaDistrubutionErrorBarsVsHomophilyLevels;		
	}
	
	public double[] getLocalAlphaListOfTheNodes()
	{
		return localAlphaListOfTheNodes;
	}
	
	public double getLocalAlphaOfTheGraph()
	{
		return localAlphaOfTheGraph;
	}
	
	void analyzeLocalAlphaDistributionOfTheGraph()
	{
		double minLA = Double.MAX_VALUE;
		double maxLA = -1;
		
		
		for(int i=0; i<localAlphaListOfTheNodes.length; i++)
		{
			if(localAlphaListOfTheNodes[i] > maxLA)
				maxLA = localAlphaListOfTheNodes[i];
			
			if(localAlphaListOfTheNodes[i] < minLA)
				minLA = localAlphaListOfTheNodes[i];
			
			precisionIntervalsForLocalAlphaDiscritization[(int) Math.floor(localAlphaListOfTheNodes[i]*(1.0/ConstantVariable.LocalAlphaRelated_ConstantVariables.PRECISION_LEVEL_FOR_LA_DISCRETIZATON))]++;
		}
		
		System.out.println("maxLocalAlpha:"+maxLA);
		System.out.println("minLocalAlpha:"+minLA);
		System.out.println("LAOfTheGraph:"+localAlphaOfTheGraph);
		
		int sifirOlmayanLASayisi=0;
		ArrayList<Double> LALevelsList = new ArrayList<Double>();
		
		
		for(int i=0; i<precisionIntervalsForLocalAlphaDiscritization.length; i++)
		{
			if(precisionIntervalsForLocalAlphaDiscritization[i]!=0)
			{
				System.out.println(i+":"+precisionIntervalsForLocalAlphaDiscritization[i]);
				sifirOlmayanLASayisi++;
				LALevelsList.add(WorkerUtilityClass.roundToDecimals((double)i*ConstantVariable.LocalAlphaRelated_ConstantVariables.PRECISION_LEVEL_FOR_LA_DISCRETIZATON, 2));
			}
		}
		
		System.out.println("sifirOlmayanCCSayisi:"+sifirOlmayanLASayisi);
		
		localAlphaLevels = WorkerUtilityClass.getDoubleArrayFromDoubleArrayList(LALevelsList);
		
		WorkerUtilityClass.printArray(localAlphaLevels, "localAlphaLevels");
		
		double localAlphaOfTheElement;
		Map<Double, Integer> localAlphaDistibutionMap = new HashMap<Double, Integer>(); 
		
		for(int i=0; i<precisionIntervalsForLocalAlphaDiscritization.length; i++)
		{
			if(precisionIntervalsForLocalAlphaDiscritization[i]>0)
			{
				localAlphaOfTheElement = (double)i*ConstantVariable.ClusteringCoefficentRelated_ConstantVariables.PRECISION_LEVEL_FOR_CC_DISCRETIZATON;
				
				double size = localAlphaOfTheElement; 
				Integer n = localAlphaDistibutionMap.get(size); 
				if (n == null) { 
					localAlphaDistibutionMap.put(size, 1); 
				} else { 
					localAlphaDistibutionMap.put(size, n + 1); 
				}								
			}		
		}			

		System.out.println(localAlphaDistibutionMap);
		
		System.out.println("Sorted LA hashmap START");
		
		System.out.println(Utility.WorkerUtilityClass.sortHashMapByValuesD((HashMap) localAlphaDistibutionMap));
		
		System.out.println("Sorted LA hashmap END");	
	}
	
	void calculateLocalAlphaVsCCDistribution()
	{
		double[] degreeListOfTheNodes = propertiesIBelongTo.degreeDistributionRelatedProps.degreeListOfNodes;
		//double[] ccListOfTheNodes = propertiesIBelongTo.clusteringCoefficientRelatedProps.clusteringCoefficientListOfTheNodes;    	
		double[] localAlphaListOfTheNodes = propertiesIBelongTo.localAlphaRelatedProps.localAlphaListOfTheNodes;    	
		double[] ccLevels=propertiesIBelongTo.clusteringCoefficientRelatedProps.ccLevels;
		
		double[] clusteringCoefficientListOfTheNodes = propertiesIBelongTo.clusteringCoefficientRelatedProps.clusteringCoefficientListOfTheNodes;
		int numberOfCCLevels = ccLevels.length;

		Map<Double, Integer> ccDistibutionMapIndex = new HashMap<Double, Integer>();

		for(int i=0; i<numberOfCCLevels; i++)
			ccDistibutionMapIndex.put(ccLevels[i], i);

		int indexOfTheCCDistList;

		ListsPerGivenLevelsHolderClass[] clusteringCoefficientLists = ListsPerGivenLevelsHolderClass.getNewLevelSeperatedList(numberOfCCLevels);


		int i=0;
		int magnifyingConstant =(int)(1.0/ConstantVariable.ClusteringCoefficentRelated_ConstantVariables.PRECISION_LEVEL_FOR_CC_DISCRETIZATON); 
		try{

			for(i=0; i<degreeListOfTheNodes.length; i++)
			{
				if(degreeListOfTheNodes[i]> 1)
				{	try
					{
						
						indexOfTheCCDistList = ccDistibutionMapIndex.get((double)((int)(clusteringCoefficientListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant);
						clusteringCoefficientLists[indexOfTheCCDistList].add(localAlphaListOfTheNodes[i]);
					}catch (Exception e) {
						// TODO: handle exception
						System.out.println("Org deger:"+clusteringCoefficientListOfTheNodes[i]);
						System.out.println("Yuvarlanan:"+(double)((int)(clusteringCoefficientListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant);
						e.printStackTrace();
					}
				}
			}
		}catch (Exception e) {
			System.out.println("i:"+i);
			System.out.println("hListOfTheNodes[i]:"+degreeListOfTheNodes[i]);
			e.printStackTrace();
			// TODO: handle exception
		}

		double[] localAlphaDistrubutionVsCCLevels;
		double[] localAlphaDistrubutionErrorBarsVsCCLevels;

		localAlphaDistrubutionVsCCLevels = new double[numberOfCCLevels];
		localAlphaDistrubutionErrorBarsVsCCLevels = new double[numberOfCCLevels];


		double[] doubleArrayFormOfTheList; 

		for(i=0; i<clusteringCoefficientLists.length; i++)
		{
			doubleArrayFormOfTheList = WorkerUtilityClass.getDoubleArrayFromDoubleArrayList(clusteringCoefficientLists[i].getArrayListOfTheDoubleValues());
			localAlphaDistrubutionVsCCLevels[i]=WorkerUtilityClass.getAverage(doubleArrayFormOfTheList);
			localAlphaDistrubutionErrorBarsVsCCLevels[i]=WorkerUtilityClass.findErrorBar(doubleArrayFormOfTheList);
			//System.out.println("i:"+i+":"+clusteringCoefficientLists[i].size() +":"+clusteringCoefficientDistrubutionErrorBarsVsDegreeLevels[i]);
		}	

		propertiesIBelongTo.localAlphaRelatedProps.setLocalAlphaVsCCRelatedParameters(localAlphaDistrubutionVsCCLevels, localAlphaDistrubutionErrorBarsVsCCLevels);
	}	

	void calculateLocalAlphaVsHomophilyDistribution()
	{
		double[] degreeListOfTheNodes = propertiesIBelongTo.degreeDistributionRelatedProps.degreeListOfNodes;
		//double[] ccListOfTheNodes = propertiesIBelongTo.clusteringCoefficientRelatedProps.clusteringCoefficientListOfTheNodes;    	
		double[] localAlphaListOfTheNodes = propertiesIBelongTo.localAlphaRelatedProps.localAlphaListOfTheNodes;    	
		double[] homophilyLevels=propertiesIBelongTo.homophilyRelatedProps.homophilyLevels;
		
		double[] homophilyListOfTheNodes = propertiesIBelongTo.homophilyRelatedProps.homophilyListOfTheNodes;
		int numberOfHomophilyLevels = homophilyLevels.length;

		Map<Double, Integer> homophilyDistibutionMapIndex = new HashMap<Double, Integer>();

		for(int i=0; i<numberOfHomophilyLevels; i++)
			homophilyDistibutionMapIndex.put(homophilyLevels[i], i);

		int indexOfTheHomophilyDistList;

		ListsPerGivenLevelsHolderClass[] homophilyLists = ListsPerGivenLevelsHolderClass.getNewLevelSeperatedList(numberOfHomophilyLevels);


		int i=0;
		int magnifyingConstant =(int)(1.0/ConstantVariable.HomophilyRelated_ConstantVariables.PRECISION_LEVEL_FOR_HOMOPHILY_DISCRETIZATON); 
		try{

			for(i=0; i<degreeListOfTheNodes.length; i++)
			{
				if(degreeListOfTheNodes[i]> 0)
				{	try
					{			
					    //int test = (int)(homophilyListOfTheNodes[i]*magnifyingConstant);
					    //double deger = (double)(((int)(homophilyListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant);
					    //System.out.println("Asil deger: "+homophilyListOfTheNodes[i]+"Yanlis deger: "+(double)((int)(homophilyListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant+" Acayip:"+(double)((int)(homophilyListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant);
						indexOfTheHomophilyDistList = homophilyDistibutionMapIndex.get(WorkerUtilityClass.roundToDecimals((double)((int)(homophilyListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant,2));
						homophilyLists[indexOfTheHomophilyDistList].add(localAlphaListOfTheNodes[i]);
					}catch (Exception e) {
						// TODO: handle exception
						System.out.println("Org deger:"+homophilyListOfTheNodes[i]);
						System.out.println("Yuvarlanan:"+(double)((int)(homophilyListOfTheNodes[i]*magnifyingConstant))/magnifyingConstant);
						e.printStackTrace();
					}
				}
			}
		}catch (Exception e) {
			System.out.println("i:"+i);
			System.out.println("hListOfTheNodes[i]:"+degreeListOfTheNodes[i]);
			e.printStackTrace();
			// TODO: handle exception
		}

		double[] localAlphaDistrubutionVsHomophilyLevels;
		double[] localAlphaDistrubutionErrorBarsVsHomophilyLevels;

		localAlphaDistrubutionVsHomophilyLevels = new double[numberOfHomophilyLevels];
		localAlphaDistrubutionErrorBarsVsHomophilyLevels = new double[numberOfHomophilyLevels];


		double[] doubleArrayFormOfTheList; 

		for(i=0; i<homophilyLists.length; i++)
		{
			doubleArrayFormOfTheList = WorkerUtilityClass.getDoubleArrayFromDoubleArrayList(homophilyLists[i].getArrayListOfTheDoubleValues());
			localAlphaDistrubutionVsHomophilyLevels[i]=WorkerUtilityClass.getAverage(doubleArrayFormOfTheList);
			localAlphaDistrubutionErrorBarsVsHomophilyLevels[i]=WorkerUtilityClass.findErrorBar(doubleArrayFormOfTheList);
			//System.out.println("i:"+i+":"+clusteringCoefficientLists[i].size() +":"+clusteringCoefficientDistrubutionErrorBarsVsDegreeLevels[i]);
		}	

		propertiesIBelongTo.localAlphaRelatedProps.setLocalAlphaVsHomophilyRelatedParameters(localAlphaDistrubutionVsHomophilyLevels, localAlphaDistrubutionErrorBarsVsHomophilyLevels);
	}	

	void localAlphaCalculationIsCompleted()
	{
		String datasetName = DirectoryStructureAndSettingsClass.getDatasetName();
		
		try {
			
			outForPureRawFile = createRawPureLocalAlphaResultsFile(datasetName);
			Utility.FileUtilityClass.writeArrayToFile(outForPureRawFile, localAlphaListOfTheNodes, ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForLocalAlphaOfNodes, "Local Alpha of Nodes for " + datasetName+ConstantVariable.Format_ConstantVariables.DASH_CHAR+propertiesIBelongTo.edgeType);
			outForPureRawFile.close();
		
			outForRawFile = createRawLocalAlphaResultsFile(datasetName);
			Utility.FileUtilityClass.writeTwoArraysToFile(outForRawFile, propertiesIBelongTo.degreeDistributionRelatedProps.degreeLevels, localAlphaDistrubutionVsDegreeLevels, ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForDegreesDistributionLevelsOfNodes, ConstantVariable.Format_ConstantVariables.numberFormatToBeUsedForLocalAlphaDistributionOfNodes, "Local Alpha Of The Graph for " + datasetName+ConstantVariable.Format_ConstantVariables.DASH_CHAR+propertiesIBelongTo.edgeType);
			outForRawFile.close();
			
			String drawingSetting = null;
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_FIGURE_FOR_LINK_GRAPH;
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_FIGURE_FOR_CONTENT_GRAPH;				
			
			outForMatlabCodeFile = createMatlabCodeLocalAlphaVsDDResultsFile(datasetName, false);
			createLocalAlphaVsDDPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, false, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.DONT_CARE, drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			outForMatlabCodeFile.close();
			
			outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
			prepareTexFileForTheCreatedMatlabFigure();			
			outForTexForMatlabFigureFile.close();
			
			copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_DD_MATLAB_FIGURES_TEX_ALL_IN_ONE_FILENAME, false);
			
			//TODO AS EKLEME YAPIYOR..AYNI PARAMETRELI DATASET PLOTLARINI AYNI GRAFTA YAPMA!!!
			if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
			{	
				TogetherFilesHolderClass currentTogetherFileHolder;
				currentTogetherFileHolder = syntheticDataGeneratorClass.getOutForMatlabCodeLAVsDDPDFResultsTogetherFile();
				String nameBackup = new String(matlabFileName);			
				matlabFileName = currentTogetherFileHolder.matlabFileName;
				outForMatlabCodeFile = currentTogetherFileHolder.out;				 
				createLocalAlphaVsDDPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.DefaultScaleTypes.DEFAULT_SCALE_TYPE_TO_BE_USED_WITH_SYNTHETIC_TOGETHER_PLOTS, true, syntheticDataGeneratorClass.getGraphOrderForTogetherGraphicResults(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE, false), drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, false);
				matlabFileName = nameBackup;
			}
			
			/**************************COMBO*********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaVsDDComboResultsFile(datasetName, false);
				createLocalAlphaVsDDPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.FIRST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_COMBO_FIGURE_FOR_LINK_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			}
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaVsDDComboResultsFile(datasetName, true);
				createLocalAlphaVsDDPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.LAST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_COMBO_FIGURE_FOR_CONTENT_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			}
				
			outForMatlabCodeFile.close();

			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
				prepareTexFileForTheCreatedMatlabFigure();			
				outForTexForMatlabFigureFile.close();
				
				copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_DD_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, true);			
			}
			
			/****************************LOCAL ALPHA VS CC BAR PLOT(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_CC_FIGURE_FOR_LINK_GRAPH;
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_CC_FIGURE_FOR_CONTENT_GRAPH;				
			
			outForMatlabCodeFile = createMatlabCodeLocalAlphaVsCCResultsFile(datasetName, false);
			createLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, false, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.DONT_CARE, drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			outForMatlabCodeFile.close();
			
			outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
			prepareTexFileForTheCreatedMatlabFigure();			
			outForTexForMatlabFigureFile.close();
			
			copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_CC_MATLAB_FIGURES_TEX_IN_ONE_FILENAME, false);
			
			//TODO AS EKLEME YAPIYOR..AYNI PARAMETRELI DATASET PLOTLARINI AYNI GRAFTA YAPMA!!!
			if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
			{	
				TogetherFilesHolderClass currentTogetherFileHolder;
				currentTogetherFileHolder = syntheticDataGeneratorClass.getOutForMatlabCodeLAVsCCPDFResultsTogetherFile();
				String nameBackup = new String(matlabFileName);			
				matlabFileName = currentTogetherFileHolder.matlabFileName;
				outForMatlabCodeFile = currentTogetherFileHolder.out;				 
				createLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.DefaultScaleTypes.DEFAULT_SCALE_TYPE_TO_BE_USED_WITH_SYNTHETIC_TOGETHER_PLOTS, true, syntheticDataGeneratorClass.getGraphOrderForTogetherGraphicResults(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE, false), drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, false);
				matlabFileName = nameBackup;
			}
			
			/****************************LOCAL ALPHA VS CC BAR PLOT COMBO(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaVsCCComboResultsFile(datasetName, false);
				createLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.FIRST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_CC_COMBO_FIGURE_FOR_LINK_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			}
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaVsCCComboResultsFile(datasetName, true);
				createLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.LAST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_CC_COMBO_FIGURE_FOR_CONTENT_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			}
				
			outForMatlabCodeFile.close();

			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
				prepareTexFileForTheCreatedMatlabFigure();			
				outForTexForMatlabFigureFile.close();
				
				copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_CC_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, true);			
			}
			
			/****************************LOCAL ALPHA VS CC DOT PLOT**********************************/
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_CC_FIGURE_FOR_LINK_GRAPH;
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_CC_FIGURE_FOR_CONTENT_GRAPH;
			
			outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsCCResultsFile(datasetName, false);
			createDotLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, false, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.DONT_CARE, drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			outForMatlabCodeFile.close();
			
			outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE);
			prepareTexFileForTheCreatedMatlabFigure();			
			outForTexForMatlabFigureFile.close();
			
			copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_CC_MATLAB_FIGURES_TEX_IN_ONE_FILENAME, false);
			
			/************************** LOCAL ALPHA VS CC DOT TOGETHER PLOTS FOR SYNTHETIC*********************************/
			//TODO AS EKLEME YAPIYOR..AYNI PARAMETRELI DATASET PLOTLARINI AYNI GRAFTA YAPMA!!!
			if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
			{	
				TogetherFilesHolderClass currentTogetherFileHolder;
				currentTogetherFileHolder = syntheticDataGeneratorClass.getOutForMatlabCodeLAVsCCPDotDFResultsTogetherFile();
				String nameBackup = new String(matlabFileName);			
				matlabFileName = currentTogetherFileHolder.matlabFileName;
				outForMatlabCodeFile = currentTogetherFileHolder.out;				 
				createDotLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, syntheticDataGeneratorClass.getGraphOrderForTogetherGraphicResults(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE, false), drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, false);
				matlabFileName = nameBackup;
			}
						
			/****************************LOCAL ALPHA VS CC DOT PLOT COMBO(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
			{
				outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsCCComboResultsFile(datasetName, false);
				createDotLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.FIRST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_CC_COMBO_FIGURE_FOR_LINK_GRAPH, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			}		
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsCCComboResultsFile(datasetName, true);
				createDotLocalAlphaVsCCPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.LAST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_CC_COMBO_FIGURE_FOR_CONTENT_GRAPH, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);				
			}
			outForMatlabCodeFile.close();
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE);
				prepareTexFileForTheCreatedMatlabFigure();			
				outForTexForMatlabFigureFile.close();
				
				copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_CC_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, true);			
			}
			
			/****************************LOCAL ALPHA VS HOMOPHILY(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_FIGURE_FOR_LINK_GRAPH;
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_FIGURE_FOR_CONTENT_GRAPH;				
			
			outForMatlabCodeFile = createMatlabCodeLocalAlphaDistributionVsHomophilyResultsFile(datasetName, false);
			createLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, false, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.DONT_CARE, drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			outForMatlabCodeFile.close();
			
			outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
			prepareTexFileForTheCreatedMatlabFigure();			
			outForTexForMatlabFigureFile.close();
			
			copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_HOMOPHILY_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, false);
			
			//TODO AS EKLEME YAPIYOR..AYNI PARAMETRELI DATASET PLOTLARINI AYNI GRAFTA YAPMA!!!
			if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
			{	
				TogetherFilesHolderClass currentTogetherFileHolder;
				currentTogetherFileHolder = syntheticDataGeneratorClass.getOutForMatlabCodeLAVsHomophilyPDFResultsTogetherFile();
				String nameBackup = new String(matlabFileName);			
				matlabFileName = currentTogetherFileHolder.matlabFileName;
				outForMatlabCodeFile = currentTogetherFileHolder.out;				 
				createLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.DefaultScaleTypes.DEFAULT_SCALE_TYPE_TO_BE_USED_WITH_SYNTHETIC_TOGETHER_PLOTS, true, syntheticDataGeneratorClass.getGraphOrderForTogetherGraphicResults(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE, false), drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, false);
				matlabFileName = nameBackup;
			}
			
			/****************************LOCAL ALPHA VS HOMOPHILY BAR PLOT COMBO(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(datasetName, false);
				createLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.FIRST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_COMBO_FIGURE_FOR_LINK_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);			
			}
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForMatlabCodeFile = createMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(datasetName, true);
				createLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.LAST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_COMBO_FIGURE_FOR_CONTENT_GRAPH, Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			}
				
			outForMatlabCodeFile.close();

			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.ERRORBAR_LINEAR_SCALE);
				prepareTexFileForTheCreatedMatlabFigure();			
				outForTexForMatlabFigureFile.close();
				
				copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_HOMOPHILY_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, true);			
			}

			
			/****************************LOCAL ALPHA VS HOMOPHILY DOT PLOT(OK)**********************************/
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_FIGURE_FOR_LINK_GRAPH;
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
				drawingSetting = ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_FIGURE_FOR_CONTENT_GRAPH ;
			
			outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsHomophilyResultsFile(datasetName, false);
			createDotLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, false, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.DONT_CARE, drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			outForMatlabCodeFile.close();
			
			outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE);
			prepareTexFileForTheCreatedMatlabFigure();			
			outForTexForMatlabFigureFile.close();
			
			copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_HOMOPHILY_MATLAB_FIGURES_TEX_IN_ONE_FILENAME, false);
			
			/************************** LOCAL ALPHA VS HOMOPHILY DOT TOGETHER PLOTS FOR SYNTHETIC*********************************/
			
			//TODO AS EKLEME YAPIYOR..AYNI PARAMETRELI DATASET PLOTLARINI AYNI GRAFTA YAPMA!!!
			if(GlobalClass.RunningValues.executionFor==ConstantVariable.DataSet_Constants.SYNTETIC_DATASET)
			{	
				TogetherFilesHolderClass currentTogetherFileHolder;
				currentTogetherFileHolder = syntheticDataGeneratorClass.getOutForMatlabCodeLAVsHomophilyDotPDFResultsTogetherFile();
				String nameBackup = new String(matlabFileName);			
				matlabFileName = currentTogetherFileHolder.matlabFileName;
				outForMatlabCodeFile = currentTogetherFileHolder.out;				 
				createDotLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, syntheticDataGeneratorClass.getGraphOrderForTogetherGraphicResults(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE, false), drawingSetting, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, false);
				matlabFileName = nameBackup;
			}
			
			/****************************LOCAL ALPHA VS HOMOPHILY DOT PLOT COMBO(OK)**********************************/
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE)
			{
				outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(datasetName, false);
				createDotLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.FIRST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_COMBO_FIGURE_FOR_LINK_GRAPH, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);
			}		
			else if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForMatlabCodeFile = createDotMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(datasetName, true);
				createDotLocalAlphaVsHomophilyPlotCodeForMatlab(outForMatlabCodeFile, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE, true, ConstantVariable.Matlab_ConstantVariables.GraphOrderType.LAST_GRAPH, ConstantVariable.Matlab_ConstantVariables.DrawingSettings.LARelatedDrawingSettings.DRAWING_SETTING_FOR_DOT_LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_COMBO_FIGURE_FOR_CONTENT_GRAPH, ConstantVariable.Matlab_ConstantVariables.DistributionType.PDF_TYPE, true);				
			}
			outForMatlabCodeFile.close();
			
			if(propertiesIBelongTo.edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			{
				outForTexForMatlabFigureFile = createTexFileForTheGeneratedMatlabFigure(propertiesIBelongTo.edgeType, ConstantVariable.Matlab_ConstantVariables.ScaleType.LINEAR_SCALE);
				prepareTexFileForTheCreatedMatlabFigure();			
				outForTexForMatlabFigureFile.close();
				
				copyTexForTheFigureTo(ConstantVariable.DefaultFileNamesConstants.DefaultAllInOneResultsFiles.LOCAL_ALPHA_VS_HOMOPHILY_MATLAB_FIGURES_TEX_COMBO_IN_ONE_FILENAME, true);			
			}

		} catch (IOException e) {			
			e.printStackTrace();
		}		
	}	
	
	 public BufferedWriter createRawPureLocalAlphaResultsFile(String datasetName)
	 {
		 String path= DirectoryStructureAndSettingsClass.getFullPathOfTheRootDirectoryNameForTheCurrentDataset()
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.GRAPH_PROPERTIES_FOLDER_NAME
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.LOCAL_ALPHA_RELATED_DATA_FOLDER_NAME    				
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.RAW_DATA_FOLDER_NAME;

		 String fileName = datasetName+ConstantVariable.Format_ConstantVariables.DASH_CHAR+propertiesIBelongTo.edgeType+ConstantVariable.Format_ConstantVariables.DASH_CHAR+"LocalAlphasOfNodes.txt"; 
		 try {

			 File descFile=DirectoryStructureAndSettingsClass.createFile(path, fileName);
			 FileWriter fstream;
			 fstream = new FileWriter(descFile);
			 BufferedWriter out = new BufferedWriter(fstream);
			 return out;
		 } catch (IOException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return null;
	 }

	 /**********************************************/

	 public BufferedWriter createRawLocalAlphaResultsFile(String datasetName)
	 {
		 String path= DirectoryStructureAndSettingsClass.getFullPathOfTheRootDirectoryNameForTheCurrentDataset()
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.GRAPH_PROPERTIES_FOLDER_NAME
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.LOCAL_ALPHA_RELATED_DATA_FOLDER_NAME
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.RAW_DATA_FOLDER_NAME;

		 String fileName = datasetName+ConstantVariable.Format_ConstantVariables.DASH_CHAR+propertiesIBelongTo.edgeType+ConstantVariable.Format_ConstantVariables.DASH_CHAR+"LocalAlphaVsDegreeDistribution.txt"; 
		 try {

			 File descFile=DirectoryStructureAndSettingsClass.createFile(path, fileName);
			 FileWriter fstream;
			 fstream = new FileWriter(descFile);
			 BufferedWriter out = new BufferedWriter(fstream);
			 return out;
		 } catch (IOException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return null;
	 }

	 /**********************************************/

	 public BufferedWriter createMatlabCodeLocalAlphaVsDDResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_DISTRIBUTION_RESULTS_FILE_SUFFIX, appendMode, true);
	 }
	 
	 public BufferedWriter createMatlabCodeLocalAlphaVsDDComboResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_DEGREE_DISTRIBUTION_COMBO_RESULTS_FILE_SUFFIX, appendMode, false);
	 }
	 
	 /*******************Matlab Files for Local Alpha Versus Clustering Coefficient ***************************/
	 
	 public BufferedWriter createMatlabCodeLocalAlphaVsCCResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_CLUSTERING_COEFFICIENT_RESULTS_FILE_SUFFIX, appendMode, true);
	 }
	 
	 public BufferedWriter createMatlabCodeLocalAlphaVsCCComboResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_CLUSTERING_COEFFICIENT_COMBO_RESULTS_FILE_SUFFIX, appendMode, false);
	 }
	 

	 public BufferedWriter createDotMatlabCodeLocalAlphaDistributionVsCCResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DOT_DISTRIBUTION_VS_CLUSTERING_COEFFICIENT_RESULTS_FILE_SUFFIX, appendMode, true);    	
	 }

	 public BufferedWriter createDotMatlabCodeLocalAlphaDistributionVsCCComboResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DOT_DISTRIBUTION_VS_CLUSTERING_COEFFICIENT_COMBO_RESULTS_FILE_SUFFIX, appendMode, false);
	 }
	 
	 /*******************Matlab Files for Local Alpha Versus Homophily***************************/
	 
	 public BufferedWriter createMatlabCodeLocalAlphaDistributionVsHomophilyResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_RESULTS_FILE_SUFFIX, appendMode, true);    	
	 }

	 public BufferedWriter createMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DISTRIBUTION_VS_HOMOPHILY_COMBO_RESULTS_FILE_SUFFIX, appendMode, false);
	 }

	 public BufferedWriter createDotMatlabCodeLocalAlphaDistributionVsHomophilyResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DOT_DISTRIBUTION_VS_HOMOPHILY_RESULTS_FILE_SUFFIX, appendMode, true);    	
	 }

	 public BufferedWriter createDotMatlabCodeLocalAlphaDistributionVsHomophilyComboResultsFile(String datasetName, boolean appendMode)
	 {
		 return createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(datasetName, ConstantVariable.GraphPropertiesSuffixes.LAPropertiesSuffixes.LOCAL_ALPHA_DOT_DISTRIBUTION_VS_HOMOPHILY_COMBO_RESULTS_FILE_SUFFIX, appendMode, false);
	 }
	 /*******************************************************************************************************/    

	 public BufferedWriter createMatlabCodeFilesUnderMatlabCodeDirectoryForLocalAlpha(String datasetName, String suffixForTheFileName, boolean appendMode, boolean includeEdgeType)
	 {
		 String path= DirectoryStructureAndSettingsClass.getFullPathOfTheRootDirectoryNameForTheCurrentDataset()
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderDatasetDirectory.GRAPH_PROPERTIES_FOLDER_NAME
		 +ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGraphPropertiesDirectory.LOCAL_ALPHA_RELATED_DATA_FOLDER_NAME;

		 fullPathOfParentDirectoryOfMatlabCode = path;    	
		 path = path + ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderGenericGraphPropertyDirectory.MATLAB_CODE_FOLDER_NAME;

		 String fileName = datasetName+ConstantVariable.Format_ConstantVariables.DASH_CHAR;
		 if(includeEdgeType)
			 fileName += propertiesIBelongTo.edgeType+ConstantVariable.Format_ConstantVariables.DASH_CHAR;
		 fileName +=suffixForTheFileName;    	

		 matlabFileName = fileName;
		 fullPathOfTheMatlabFile = path;

		 fileName += ".m";

		 return DirectoryStructureAndSettingsClass.createTheFileSpecified(path, fileName, appendMode);
	 }


	 void calculateLocalAlphaVsDegreeDistribution()
	 {
		 double[] degreeLevels=propertiesIBelongTo.degreeDistributionRelatedProps.degreeLevels;
		 int numberOfDegreeLevels = degreeLevels.length;

		 double[] degreeListOfTheNodes = propertiesIBelongTo.degreeDistributionRelatedProps.degreeListOfNodes;	    	

		 Map<Double, Integer> degreeDistibutionMapIndex = new HashMap<Double, Integer>();

		 for(int i=0; i<numberOfDegreeLevels; i++)
			 degreeDistibutionMapIndex.put(degreeLevels[i], i);

		 int indexOfTheDegreeDistList;
		 
		 ListsPerGivenLevelsHolderClass[] localAlphaLists = ListsPerGivenLevelsHolderClass.getNewLevelSeperatedList(numberOfDegreeLevels);
		 
		 for(int i=0; i<degreeListOfTheNodes.length; i++)
		 {
			 if(degreeListOfTheNodes[i]!=0)
			 {
				 indexOfTheDegreeDistList = degreeDistibutionMapIndex.get(WorkerUtilityClass.convertToSomeScale(degreeListOfTheNodes[i]));
				 localAlphaLists[indexOfTheDegreeDistList].add(localAlphaListOfTheNodes[i]);				 
			 }
		 }
		 
		 localAlphaDistrubutionVsDegreeLevels = new double[numberOfDegreeLevels];
		 localAlphaDistrubutionErrorBarsVsDegreeLevels = new double[numberOfDegreeLevels];
		 
		 double[] doubleArrayFormOfTheList; 
		 
		 for(int i=0; i<localAlphaLists.length; i++)
		 {
			 doubleArrayFormOfTheList = WorkerUtilityClass.getDoubleArrayFromDoubleArrayList(localAlphaLists[i].getArrayListOfTheDoubleValues());
			 localAlphaDistrubutionVsDegreeLevels[i]=WorkerUtilityClass.getAverage(doubleArrayFormOfTheList);
			 localAlphaDistrubutionErrorBarsVsDegreeLevels[i]=WorkerUtilityClass.findErrorBar(doubleArrayFormOfTheList);
			 //System.out.println("i:"+i+":"+localAlphaLists[i].size() +":"+localAlphaDistrubutionErrorBarsVsDegreeLevels[i]);
		 }   	
	 }
	 
	 void createLocalAlphaVsDDPlotCodeForMatlab(BufferedWriter outForMatlabCodeFile, int type, boolean isForCombo, int order, String drawingSettings, int distributionPlotType, boolean generateFigure)
	 {    
		double[] degreeLevels = propertiesIBelongTo.degreeDistributionRelatedProps.degreeLevels;
	    createPlotCodeForMatlab(outForMatlabCodeFile, type, isForCombo, order, degreeLevels, localAlphaDistrubutionVsDegreeLevels, localAlphaDistrubutionErrorBarsVsDegreeLevels, "Local Alpha vs Degree Distribution", "Degree (D)", "Local Alpha (LA)", drawingSettings, distributionPlotType, generateFigure);	 
	 }
	 
	 void createLocalAlphaVsCCPlotCodeForMatlab(BufferedWriter outForMatlabCodeFile, int type, boolean isForCombo, int order, String drawingSettings, int distributionPlotType, boolean generateFigure)
	 {    
		double[] ccLevels = propertiesIBelongTo.clusteringCoefficientRelatedProps.ccLevels;
	    createPlotCodeForMatlab(outForMatlabCodeFile, type, isForCombo, order, ccLevels, localAlphaDistrubutionVsCC, localAlphaDistrubutionErrorBarsVsCC, "Local Alpha vs Clustering Coefficient", "Clustering Coefficient (C)", "Local Alpha (LA)", drawingSettings, distributionPlotType, generateFigure);	 
	 }
	 
	 void createDotLocalAlphaVsCCPlotCodeForMatlab(BufferedWriter outForMatlabCodeFile, int type, boolean isForCombo, int order, String drawingSettings, int distributionPlotType, boolean generateFigure)
	 {    	
		 double[] clusteringCoefficientListOfTheNodes = propertiesIBelongTo.clusteringCoefficientRelatedProps.getClusteringCoefficientListOfTheNodes();    	
		 createPlotCodeForMatlab(outForMatlabCodeFile, type, isForCombo, order, clusteringCoefficientListOfTheNodes, localAlphaListOfTheNodes, null, "Local Alpha vs Clustering Coefficient", "Clustering Coefficient (C)", "Local Alpha (LA)", drawingSettings, distributionPlotType, generateFigure);
	 }
	 
	 void createLocalAlphaVsHomophilyPlotCodeForMatlab(BufferedWriter outForMatlabCodeFile, int type, boolean isForCombo, int order, String drawingSettings, int distributionPlotType, boolean generateFigure)
	 {    
		double[] homophilyLevels = propertiesIBelongTo.homophilyRelatedProps.homophilyLevels;
		createPlotCodeForMatlab(outForMatlabCodeFile, type, isForCombo, order, homophilyLevels, localAlphaDistrubutionVsHomophily, localAlphaDistrubutionErrorBarsVsHomophily, "Local Alpha vs Homophily", "Homophily (h)", "Local Alpha (LA)", drawingSettings, distributionPlotType, generateFigure);		
	 }
	 
	 void createDotLocalAlphaVsHomophilyPlotCodeForMatlab(BufferedWriter outForMatlabCodeFile, int type, boolean isForCombo, int order, String drawingSettings, int distributionPlotType, boolean generateFigure)
	 {    	
		 double[] homophilyListOfTheNodes = propertiesIBelongTo.homophilyRelatedProps.getHomophilyListOfTheNodes();    	
		 createPlotCodeForMatlab(outForMatlabCodeFile, type, isForCombo, order, homophilyListOfTheNodes, localAlphaListOfTheNodes, null, "Local Alpha vs Homophily", "Homophily (h)", "Local Alpha (LA)", drawingSettings, distributionPlotType, generateFigure);
	 }
}
